package com.fieldchain.ex.fa100.ui.personal.activity;

import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.Context;
import android.content.Intent;
import android.view.View;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.fieldchain.ex.fa100.R;
import com.fieldchain.ex.fa100.base.MyBaseActivity;

import com.fieldchain.ex.fa100.utils.screen.MyToast;

/**
 * Created by biyunlong
 * Email: 1225198434@qq.com
 * Data:  2018/9/16
 */
public class InvitationActivity extends MyBaseActivity implements View.OnClickListener {
    private RelativeLayout reaBack;
    private TextView tvCenter;
    private TextView tvNum;
    private TextView tvAddress;
    private TextView tvCopy;
    private TextView tvSure;

    @Override
    public void findView() {
        reaBack = findViewById(R.id.rea_back);
        tvCenter = findViewById(R.id.tv_center);
        tvNum = findViewById(R.id.tv_num);
        tvAddress = findViewById(R.id.tv_address);
        tvCopy = findViewById(R.id.tv_copy);
        tvSure = findViewById(R.id.tv_sure);
    }

    @Override
    public void setValue() {
        tvCenter.setText("邀请好友");
        reaBack.setOnClickListener(this);
        tvCopy.setOnClickListener(this);
        tvSure.setOnClickListener(this);
    }

    @Override
    public int getLayout() {
        return R.layout.activity_invitation;
    }

    @Override
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.rea_back:
                finish();
                break;
            case R.id.tv_copy:
                ClipboardManager cm = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
                // 将文本内容放到系统剪贴板里。
                ClipData clipData = ClipData.newPlainText("邀请码", tvAddress.getText().toString());
                cm.setPrimaryClip(clipData);
                MyToast.show(this, "复制成功");
                break;
            case R.id.tv_sure:
                startActivity(new Intent(mContext,InviteListActivity.class));
                break;
        }
    }
}
